@farm.js/core 0.1.0-beta.22 → 0.1.0-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-runtime.d.mts +2 -1
- package/dist/agent-runtime.d.ts +2 -1
- package/dist/{app-DwsTpyNZ.d.mts → app-DrFCUMHY.d.mts} +6 -3
- package/dist/app-markdown.d.mts +2 -1
- package/dist/app-markdown.d.ts +2 -1
- package/dist/{app-BB8GCH1g.d.ts → app-pwvKG2B1.d.ts} +6 -3
- package/dist/chunk-4IVNW5QD.mjs +82 -0
- package/dist/chunk-4IVNW5QD.mjs.map +1 -0
- package/dist/chunk-D42BNPZH.mjs +79 -0
- package/dist/chunk-D42BNPZH.mjs.map +1 -0
- package/dist/{chunk-LLPN5SEZ.mjs → chunk-DVPRBMU2.mjs} +2 -2
- package/dist/chunk-GQVQESLY.mjs +25 -0
- package/dist/chunk-GQVQESLY.mjs.map +1 -0
- package/dist/chunk-H53KVQUU.mjs +48 -0
- package/dist/chunk-H53KVQUU.mjs.map +1 -0
- package/dist/chunk-HCGQYYHI.mjs +1 -0
- package/dist/chunk-HCGQYYHI.mjs.map +1 -0
- package/dist/{chunk-XBKXKJX5.mjs → chunk-HVJHNKSP.mjs} +220 -63
- package/dist/chunk-HVJHNKSP.mjs.map +1 -0
- package/dist/{chunk-ZP73P4VR.mjs → chunk-HXE4VGH2.mjs} +79 -20
- package/dist/chunk-HXE4VGH2.mjs.map +1 -0
- package/dist/{chunk-UCYWGN2P.mjs → chunk-OHNSROHS.mjs} +1 -1
- package/dist/{chunk-FRPWCMMG.mjs → chunk-SBWOTAX4.mjs} +63 -2
- package/dist/chunk-SBWOTAX4.mjs.map +1 -0
- package/dist/{chunk-DAUR3WUZ.mjs → chunk-WO466YX5.mjs} +2 -2
- package/dist/chunk-WO466YX5.mjs.map +1 -0
- package/dist/{chunk-CEVMYGDL.mjs → chunk-YD5IRKVS.mjs} +13 -9
- package/dist/chunk-YD5IRKVS.mjs.map +1 -0
- package/dist/{client-plugins-QQntVkrv.d.mts → client-plugins-CCilIb_G.d.mts} +6 -2
- package/dist/{client-plugins-CbRum1fj.d.ts → client-plugins-DuuleQKk.d.ts} +6 -2
- package/dist/client-plugins.d.mts +2 -1
- package/dist/client-plugins.d.ts +2 -1
- package/dist/client.cjs +122 -35
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.mts +2 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.mjs +13 -2
- package/dist/config.d.mts +2 -1
- package/dist/config.d.ts +2 -1
- package/dist/{devtools-52FYXIEK.mjs → devtools-326RBQCN.mjs} +7 -6
- package/dist/{devtools-52FYXIEK.mjs.map → devtools-326RBQCN.mjs.map} +1 -1
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.mjs +6 -5
- package/dist/index.cjs +910 -414
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.mjs +66 -49
- package/dist/index.mjs.map +1 -1
- package/dist/integrations.d.mts +2 -1
- package/dist/integrations.d.ts +2 -1
- package/dist/internal/build-runtime.cjs +720 -297
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.d.mts +4 -3
- package/dist/internal/build-runtime.d.ts +4 -3
- package/dist/internal/build-runtime.mjs +15 -12
- package/dist/internal/config-runtime.cjs +41 -0
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +3 -2
- package/dist/internal/config-runtime.d.ts +3 -2
- package/dist/internal/config-runtime.mjs +5 -4
- package/dist/internal/production-runtime.cjs +178 -0
- package/dist/internal/production-runtime.cjs.map +1 -1
- package/dist/internal/production-runtime.d.mts +20 -6
- package/dist/internal/production-runtime.d.ts +20 -6
- package/dist/internal/production-runtime.mjs +13 -1
- package/dist/internal/production-runtime.mjs.map +1 -1
- package/dist/{metadata-B5jBJHq1.d.ts → metadata-DyPRG0wX.d.ts} +1 -1
- package/dist/{metadata-BxOJ4FJl.d.mts → metadata-_GHcAySx.d.mts} +1 -1
- package/dist/middleware.d.mts +4 -3
- package/dist/middleware.d.ts +4 -3
- package/dist/plugin.cjs +461 -155
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +2 -1
- package/dist/plugin.d.ts +2 -1
- package/dist/plugin.mjs +11 -8
- package/dist/{production-runtime-Bxua86uR.d.mts → production-runtime-C4cO3esK.d.mts} +1 -1
- package/dist/{production-runtime-CZqXjRVi.d.ts → production-runtime-DrEy8kBO.d.ts} +1 -1
- package/dist/{request-7V0GaZK_.d.mts → request-B2PpOxYK.d.mts} +1 -1
- package/dist/{request-B5XYBv5a.d.ts → request-D40lt6aN.d.ts} +1 -1
- package/dist/request.d.mts +3 -2
- package/dist/request.d.ts +3 -2
- package/dist/routes.d.mts +2 -1
- package/dist/routes.d.ts +2 -1
- package/dist/server-plugins.d.mts +3 -2
- package/dist/server-plugins.d.ts +3 -2
- package/dist/server.cjs +490 -167
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +8 -6
- package/dist/server.d.ts +8 -6
- package/dist/server.mjs +20 -11
- package/dist/server.mjs.map +1 -1
- package/dist/testing.d.mts +2 -1
- package/dist/testing.d.ts +2 -1
- package/dist/theme/client.cjs +115 -0
- package/dist/theme/client.cjs.map +1 -0
- package/dist/theme/client.d.mts +17 -0
- package/dist/theme/client.d.ts +17 -0
- package/dist/theme/client.mjs +16 -0
- package/dist/theme/client.mjs.map +1 -0
- package/dist/theme/index.cjs +71 -0
- package/dist/theme/index.cjs.map +1 -0
- package/dist/theme/index.d.mts +6 -0
- package/dist/theme/index.d.ts +6 -0
- package/dist/theme/index.mjs +9 -0
- package/dist/theme/index.mjs.map +1 -0
- package/dist/theme/server.cjs +191 -0
- package/dist/theme/server.cjs.map +1 -0
- package/dist/theme/server.d.mts +8 -0
- package/dist/theme/server.d.ts +8 -0
- package/dist/theme/server.mjs +18 -0
- package/dist/theme/server.mjs.map +1 -0
- package/dist/types-CsR8fpgF.d.mts +30 -0
- package/dist/types-CsR8fpgF.d.ts +30 -0
- package/dist/{utils-xTFxzu47.d.ts → utils-3sQgfkya.d.ts} +1 -1
- package/dist/{utils-s9pN0Yep.d.mts → utils-Bop7bly-.d.mts} +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +485 -157
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.mjs +11 -8
- package/package.json +25 -1
- package/dist/chunk-CEVMYGDL.mjs.map +0 -1
- package/dist/chunk-DAUR3WUZ.mjs.map +0 -1
- package/dist/chunk-FRPWCMMG.mjs.map +0 -1
- package/dist/chunk-XBKXKJX5.mjs.map +0 -1
- package/dist/chunk-ZP73P4VR.mjs.map +0 -1
- /package/dist/{chunk-LLPN5SEZ.mjs.map → chunk-DVPRBMU2.mjs.map} +0 -0
- /package/dist/{chunk-UCYWGN2P.mjs.map → chunk-OHNSROHS.mjs.map} +0 -0
package/dist/agent-runtime.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChildProcess } from 'node:child_process';
|
|
2
|
-
import { _ as BundleResultPayload, $ as FarmPlugin, a0 as FarmIntegration } from './client-plugins-
|
|
2
|
+
import { _ as BundleResultPayload, $ as FarmPlugin, a0 as FarmIntegration } from './client-plugins-CCilIb_G.mjs';
|
|
3
3
|
import './plugin-BJDf43dc.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'http';
|
|
@@ -21,6 +21,7 @@ import './server-fn-error-DDh14a0V.mjs';
|
|
|
21
21
|
import './image-config-Duob7wER.mjs';
|
|
22
22
|
import './types-BMxWr97v.mjs';
|
|
23
23
|
import './cache.mjs';
|
|
24
|
+
import './types-CsR8fpgF.mjs';
|
|
24
25
|
import './route-runtime-DoOHzCAD.mjs';
|
|
25
26
|
import './font.mjs';
|
|
26
27
|
|
package/dist/agent-runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChildProcess } from 'node:child_process';
|
|
2
|
-
import { _ as BundleResultPayload, $ as FarmPlugin, a0 as FarmIntegration } from './client-plugins-
|
|
2
|
+
import { _ as BundleResultPayload, $ as FarmPlugin, a0 as FarmIntegration } from './client-plugins-DuuleQKk.js';
|
|
3
3
|
import './plugin-BJDf43dc.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'http';
|
|
@@ -21,6 +21,7 @@ import './server-fn-error-DDh14a0V.js';
|
|
|
21
21
|
import './image-config-Duob7wER.js';
|
|
22
22
|
import './types-BMxWr97v.js';
|
|
23
23
|
import './cache.js';
|
|
24
|
+
import './types-CsR8fpgF.js';
|
|
24
25
|
import './route-runtime-DoOHzCAD.js';
|
|
25
26
|
import './font.js';
|
|
26
27
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FarmConfig, C as ParsedRoute, s as RouteModule, v as LayoutModule, I as SSGCollectionResult, x as FarmRequest, y as FarmResponse,
|
|
1
|
+
import { F as FarmConfig, C as ParsedRoute, s as RouteModule, v as LayoutModule, I as SSGCollectionResult, x as FarmRequest, y as FarmResponse, a4 as FarmMdxResolvedConfig, a5 as ResolvedFarmDevtoolsConfig, a6 as ResolvedFarmAuthConfig, a7 as ResolvedFarmPerformanceConfig, a8 as ResolvedFarmSecurityConfig } from './client-plugins-CCilIb_G.mjs';
|
|
2
2
|
import { F as FarmDocsResolvedConfig } from './types-DTzm4TCl.mjs';
|
|
3
3
|
import { FarmMarkdownResolvedConfig } from './markdown.mjs';
|
|
4
4
|
import { F as FarmWorkflowsResolvedConfig } from './workflows-CusFV6mn.mjs';
|
|
@@ -6,11 +6,12 @@ import { FarmCronResolvedConfig } from './cron.mjs';
|
|
|
6
6
|
import { R as ResolvedFarmImageConfig } from './image-config-Duob7wER.mjs';
|
|
7
7
|
import { ProgrammaticRedirectRoute, ProgrammaticRouteSearchClientOptions } from './routes.mjs';
|
|
8
8
|
import { ViteDevServer } from 'vite';
|
|
9
|
-
import { M as MetadataImageKind } from './metadata-
|
|
9
|
+
import { M as MetadataImageKind } from './metadata-_GHcAySx.mjs';
|
|
10
10
|
import { F as FarmIslandStrategy } from './island-CfGru1MO.mjs';
|
|
11
11
|
import { R as ResolvedFarmRouteRuntimeConfig } from './route-runtime-DoOHzCAD.mjs';
|
|
12
12
|
import { R as ResolvedFarmI18nConfig } from './types-BMxWr97v.mjs';
|
|
13
13
|
import { F as FarmI18nRuntime } from './runtime-Cxpq6xZN.mjs';
|
|
14
|
+
import { R as ResolvedFarmThemeConfig } from './types-CsR8fpgF.mjs';
|
|
14
15
|
|
|
15
16
|
declare const STATIC_METADATA_IMAGE_EXTENSIONS: readonly ["png", "jpg", "jpeg", "gif", "webp"];
|
|
16
17
|
type StaticMetadataImageExtension = (typeof STATIC_METADATA_IMAGE_EXTENSIONS)[number];
|
|
@@ -141,6 +142,7 @@ declare class RouteManager {
|
|
|
141
142
|
shouldHydrate: boolean;
|
|
142
143
|
isClientComponent: boolean;
|
|
143
144
|
islandStrategy: FarmIslandStrategy | null;
|
|
145
|
+
suppressedAsyncHydration?: true;
|
|
144
146
|
search?: ProgrammaticRouteSearchClientOptions;
|
|
145
147
|
segments: Array<{
|
|
146
148
|
segment: string;
|
|
@@ -273,7 +275,7 @@ declare class ServerRenderer {
|
|
|
273
275
|
private getDeploymentId;
|
|
274
276
|
}
|
|
275
277
|
|
|
276
|
-
type NormalizedFarmConfig = Omit<Required<FarmConfig>, "devtools" | "images" | "i18n" | "performance" | "security"> & {
|
|
278
|
+
type NormalizedFarmConfig = Omit<Required<FarmConfig>, "devtools" | "images" | "i18n" | "performance" | "security" | "theme"> & {
|
|
277
279
|
docs: FarmDocsResolvedConfig;
|
|
278
280
|
md: FarmMarkdownResolvedConfig;
|
|
279
281
|
mdx: FarmMdxResolvedConfig;
|
|
@@ -285,6 +287,7 @@ type NormalizedFarmConfig = Omit<Required<FarmConfig>, "devtools" | "images" | "
|
|
|
285
287
|
auth: ResolvedFarmAuthConfig;
|
|
286
288
|
performance: ResolvedFarmPerformanceConfig;
|
|
287
289
|
security: ResolvedFarmSecurityConfig;
|
|
290
|
+
theme: ResolvedFarmThemeConfig;
|
|
288
291
|
};
|
|
289
292
|
declare class FarmApp {
|
|
290
293
|
private config;
|
package/dist/app-markdown.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export { df as FarmMarkdownPageModuleInput, de as FarmMarkdownPageSource, db as FarmMdxComponent, dc as FarmMdxComponents,
|
|
2
|
+
export { df as FarmMarkdownPageModuleInput, de as FarmMarkdownPageSource, db as FarmMdxComponent, dc as FarmMdxComponents, a4 as FarmMdxResolvedConfig, dd as FarmMdxUserConfig, dm as createFarmMarkdownRouteModule, dn as createFarmMarkdownRouteModuleFromFile, dq as createFarmMarkdownSourceResponse, dl as createMarkdownMetadata, dh as isFarmMarkdownPageFile, dp as loadFarmMdxComponents, di as normalizeFarmMarkdownRoutePath, dj as parseMarkdownFrontmatter, dg as resolveMdxConfig, dk as titleFromMarkdown } from './client-plugins-CCilIb_G.mjs';
|
|
3
3
|
import './plugin-BJDf43dc.mjs';
|
|
4
4
|
import 'http';
|
|
5
5
|
import './types-D1A6-XvH.mjs';
|
|
@@ -20,5 +20,6 @@ import './server-fn-error-DDh14a0V.mjs';
|
|
|
20
20
|
import './image-config-Duob7wER.mjs';
|
|
21
21
|
import './types-BMxWr97v.mjs';
|
|
22
22
|
import './cache.mjs';
|
|
23
|
+
import './types-CsR8fpgF.mjs';
|
|
23
24
|
import './route-runtime-DoOHzCAD.mjs';
|
|
24
25
|
import './font.mjs';
|
package/dist/app-markdown.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export { df as FarmMarkdownPageModuleInput, de as FarmMarkdownPageSource, db as FarmMdxComponent, dc as FarmMdxComponents,
|
|
2
|
+
export { df as FarmMarkdownPageModuleInput, de as FarmMarkdownPageSource, db as FarmMdxComponent, dc as FarmMdxComponents, a4 as FarmMdxResolvedConfig, dd as FarmMdxUserConfig, dm as createFarmMarkdownRouteModule, dn as createFarmMarkdownRouteModuleFromFile, dq as createFarmMarkdownSourceResponse, dl as createMarkdownMetadata, dh as isFarmMarkdownPageFile, dp as loadFarmMdxComponents, di as normalizeFarmMarkdownRoutePath, dj as parseMarkdownFrontmatter, dg as resolveMdxConfig, dk as titleFromMarkdown } from './client-plugins-DuuleQKk.js';
|
|
3
3
|
import './plugin-BJDf43dc.js';
|
|
4
4
|
import 'http';
|
|
5
5
|
import './types-D1A6-XvH.js';
|
|
@@ -20,5 +20,6 @@ import './server-fn-error-DDh14a0V.js';
|
|
|
20
20
|
import './image-config-Duob7wER.js';
|
|
21
21
|
import './types-BMxWr97v.js';
|
|
22
22
|
import './cache.js';
|
|
23
|
+
import './types-CsR8fpgF.js';
|
|
23
24
|
import './route-runtime-DoOHzCAD.js';
|
|
24
25
|
import './font.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FarmConfig, C as ParsedRoute, s as RouteModule, v as LayoutModule, I as SSGCollectionResult, x as FarmRequest, y as FarmResponse,
|
|
1
|
+
import { F as FarmConfig, C as ParsedRoute, s as RouteModule, v as LayoutModule, I as SSGCollectionResult, x as FarmRequest, y as FarmResponse, a4 as FarmMdxResolvedConfig, a5 as ResolvedFarmDevtoolsConfig, a6 as ResolvedFarmAuthConfig, a7 as ResolvedFarmPerformanceConfig, a8 as ResolvedFarmSecurityConfig } from './client-plugins-DuuleQKk.js';
|
|
2
2
|
import { F as FarmDocsResolvedConfig } from './types-DTzm4TCl.js';
|
|
3
3
|
import { FarmMarkdownResolvedConfig } from './markdown.js';
|
|
4
4
|
import { F as FarmWorkflowsResolvedConfig } from './workflows-CusFV6mn.js';
|
|
@@ -6,11 +6,12 @@ import { FarmCronResolvedConfig } from './cron.js';
|
|
|
6
6
|
import { R as ResolvedFarmImageConfig } from './image-config-Duob7wER.js';
|
|
7
7
|
import { ProgrammaticRedirectRoute, ProgrammaticRouteSearchClientOptions } from './routes.js';
|
|
8
8
|
import { ViteDevServer } from 'vite';
|
|
9
|
-
import { M as MetadataImageKind } from './metadata-
|
|
9
|
+
import { M as MetadataImageKind } from './metadata-DyPRG0wX.js';
|
|
10
10
|
import { F as FarmIslandStrategy } from './island-CfGru1MO.js';
|
|
11
11
|
import { R as ResolvedFarmRouteRuntimeConfig } from './route-runtime-DoOHzCAD.js';
|
|
12
12
|
import { R as ResolvedFarmI18nConfig } from './types-BMxWr97v.js';
|
|
13
13
|
import { F as FarmI18nRuntime } from './runtime-bv63eUiO.js';
|
|
14
|
+
import { R as ResolvedFarmThemeConfig } from './types-CsR8fpgF.js';
|
|
14
15
|
|
|
15
16
|
declare const STATIC_METADATA_IMAGE_EXTENSIONS: readonly ["png", "jpg", "jpeg", "gif", "webp"];
|
|
16
17
|
type StaticMetadataImageExtension = (typeof STATIC_METADATA_IMAGE_EXTENSIONS)[number];
|
|
@@ -141,6 +142,7 @@ declare class RouteManager {
|
|
|
141
142
|
shouldHydrate: boolean;
|
|
142
143
|
isClientComponent: boolean;
|
|
143
144
|
islandStrategy: FarmIslandStrategy | null;
|
|
145
|
+
suppressedAsyncHydration?: true;
|
|
144
146
|
search?: ProgrammaticRouteSearchClientOptions;
|
|
145
147
|
segments: Array<{
|
|
146
148
|
segment: string;
|
|
@@ -273,7 +275,7 @@ declare class ServerRenderer {
|
|
|
273
275
|
private getDeploymentId;
|
|
274
276
|
}
|
|
275
277
|
|
|
276
|
-
type NormalizedFarmConfig = Omit<Required<FarmConfig>, "devtools" | "images" | "i18n" | "performance" | "security"> & {
|
|
278
|
+
type NormalizedFarmConfig = Omit<Required<FarmConfig>, "devtools" | "images" | "i18n" | "performance" | "security" | "theme"> & {
|
|
277
279
|
docs: FarmDocsResolvedConfig;
|
|
278
280
|
md: FarmMarkdownResolvedConfig;
|
|
279
281
|
mdx: FarmMdxResolvedConfig;
|
|
@@ -285,6 +287,7 @@ type NormalizedFarmConfig = Omit<Required<FarmConfig>, "devtools" | "images" | "
|
|
|
285
287
|
auth: ResolvedFarmAuthConfig;
|
|
286
288
|
performance: ResolvedFarmPerformanceConfig;
|
|
287
289
|
security: ResolvedFarmSecurityConfig;
|
|
290
|
+
theme: ResolvedFarmThemeConfig;
|
|
288
291
|
};
|
|
289
292
|
declare class FarmApp {
|
|
290
293
|
private config;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveFarmThemeConfig
|
|
3
|
+
} from "./chunk-H53KVQUU.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getCurrentRequest
|
|
6
|
+
} from "./chunk-RHIFZZUI.mjs";
|
|
7
|
+
import {
|
|
8
|
+
_setFarmThemeServerSnapshotResolver
|
|
9
|
+
} from "./chunk-GQVQESLY.mjs";
|
|
10
|
+
import {
|
|
11
|
+
__name
|
|
12
|
+
} from "./chunk-CGILA3WO.mjs";
|
|
13
|
+
|
|
14
|
+
// src/theme/server.ts
|
|
15
|
+
var defaultThemeConfig = resolveFarmThemeConfig(void 0);
|
|
16
|
+
function _setDefaultFarmThemeConfig(config, basePath = "/") {
|
|
17
|
+
defaultThemeConfig = resolveFarmThemeConfig(config, basePath);
|
|
18
|
+
}
|
|
19
|
+
__name(_setDefaultFarmThemeConfig, "_setDefaultFarmThemeConfig");
|
|
20
|
+
function getTheme(request = getCurrentRequest()) {
|
|
21
|
+
return readFarmThemePreference(request, defaultThemeConfig);
|
|
22
|
+
}
|
|
23
|
+
__name(getTheme, "getTheme");
|
|
24
|
+
function getThemeSnapshot(request = getCurrentRequest()) {
|
|
25
|
+
const theme = readFarmThemePreference(request, defaultThemeConfig);
|
|
26
|
+
return {
|
|
27
|
+
theme,
|
|
28
|
+
resolvedTheme: theme === "system" ? void 0 : theme,
|
|
29
|
+
mounted: false
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
__name(getThemeSnapshot, "getThemeSnapshot");
|
|
33
|
+
function readFarmThemePreference(request, config) {
|
|
34
|
+
if (!config.enabled) return config.default;
|
|
35
|
+
const stored = readCookie(request.headers.get("cookie"), config.storageKey);
|
|
36
|
+
return isFarmThemePreference(stored) ? stored : config.default;
|
|
37
|
+
}
|
|
38
|
+
__name(readFarmThemePreference, "readFarmThemePreference");
|
|
39
|
+
function readCookie(cookieHeader, name) {
|
|
40
|
+
if (!cookieHeader) return void 0;
|
|
41
|
+
for (const entry of cookieHeader.split(";")) {
|
|
42
|
+
const separator = entry.indexOf("=");
|
|
43
|
+
if (separator < 0) continue;
|
|
44
|
+
const key = decodeCookieValue(entry.slice(0, separator).trim());
|
|
45
|
+
if (key !== name) continue;
|
|
46
|
+
return decodeCookieValue(entry.slice(separator + 1).trim());
|
|
47
|
+
}
|
|
48
|
+
return void 0;
|
|
49
|
+
}
|
|
50
|
+
__name(readCookie, "readCookie");
|
|
51
|
+
function decodeCookieValue(value) {
|
|
52
|
+
try {
|
|
53
|
+
return decodeURIComponent(value);
|
|
54
|
+
} catch {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
__name(decodeCookieValue, "decodeCookieValue");
|
|
59
|
+
function isFarmThemePreference(value) {
|
|
60
|
+
return value === "light" || value === "dark" || value === "system";
|
|
61
|
+
}
|
|
62
|
+
__name(isFarmThemePreference, "isFarmThemePreference");
|
|
63
|
+
_setFarmThemeServerSnapshotResolver(() => {
|
|
64
|
+
try {
|
|
65
|
+
return getThemeSnapshot();
|
|
66
|
+
} catch {
|
|
67
|
+
const theme = defaultThemeConfig.default;
|
|
68
|
+
return {
|
|
69
|
+
theme,
|
|
70
|
+
resolvedTheme: theme === "system" ? void 0 : theme,
|
|
71
|
+
mounted: false
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
_setDefaultFarmThemeConfig,
|
|
78
|
+
getTheme,
|
|
79
|
+
getThemeSnapshot,
|
|
80
|
+
readFarmThemePreference
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=chunk-4IVNW5QD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/theme/server.ts"],"sourcesContent":["import { getCurrentRequest } from \"../server/request\";\nimport { _setFarmThemeServerSnapshotResolver } from \"./bridge\";\nimport { resolveFarmThemeConfig } from \"./config\";\nimport type {\n FarmThemeConfig,\n FarmThemePreference,\n FarmThemeSnapshot,\n ResolvedFarmThemeConfig,\n} from \"./types\";\n\nlet defaultThemeConfig = resolveFarmThemeConfig(undefined);\n\nexport function _setDefaultFarmThemeConfig(\n config: FarmThemeConfig | ResolvedFarmThemeConfig | false | undefined,\n basePath = \"/\",\n): void {\n defaultThemeConfig = resolveFarmThemeConfig(config, basePath);\n}\n\nexport function getTheme(request: Request = getCurrentRequest()): FarmThemePreference {\n return readFarmThemePreference(request, defaultThemeConfig);\n}\n\nexport function getThemeSnapshot(request: Request = getCurrentRequest()): FarmThemeSnapshot {\n const theme = readFarmThemePreference(request, defaultThemeConfig);\n return {\n theme,\n resolvedTheme: theme === \"system\" ? undefined : theme,\n mounted: false,\n };\n}\n\nexport function readFarmThemePreference(\n request: Request,\n config: ResolvedFarmThemeConfig,\n): FarmThemePreference {\n if (!config.enabled) return config.default;\n const stored = readCookie(request.headers.get(\"cookie\"), config.storageKey);\n return isFarmThemePreference(stored) ? stored : config.default;\n}\n\nfunction readCookie(cookieHeader: string | null, name: string): string | undefined {\n if (!cookieHeader) return undefined;\n for (const entry of cookieHeader.split(\";\")) {\n const separator = entry.indexOf(\"=\");\n if (separator < 0) continue;\n const key = decodeCookieValue(entry.slice(0, separator).trim());\n if (key !== name) continue;\n return decodeCookieValue(entry.slice(separator + 1).trim());\n }\n return undefined;\n}\n\nfunction decodeCookieValue(value: string): string {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\nfunction isFarmThemePreference(value: unknown): value is FarmThemePreference {\n return value === \"light\" || value === \"dark\" || value === \"system\";\n}\n\n_setFarmThemeServerSnapshotResolver(() => {\n try {\n return getThemeSnapshot();\n } catch {\n const theme = defaultThemeConfig.default;\n return {\n theme,\n resolvedTheme: theme === \"system\" ? undefined : theme,\n mounted: false,\n };\n }\n});\n"],"mappings":";;;;;;;;;;;;;;AAUA,IAAI,qBAAqB,uBAAuB,MAAS;AAElD,SAAS,2BACd,QACA,WAAW,KACL;AACN,uBAAqB,uBAAuB,QAAQ,QAAQ;AAC9D;AALgB;AAOT,SAAS,SAAS,UAAmB,kBAAkB,GAAwB;AACpF,SAAO,wBAAwB,SAAS,kBAAkB;AAC5D;AAFgB;AAIT,SAAS,iBAAiB,UAAmB,kBAAkB,GAAsB;AAC1F,QAAM,QAAQ,wBAAwB,SAAS,kBAAkB;AACjE,SAAO;AAAA,IACL;AAAA,IACA,eAAe,UAAU,WAAW,SAAY;AAAA,IAChD,SAAS;AAAA,EACX;AACF;AAPgB;AAST,SAAS,wBACd,SACA,QACqB;AACrB,MAAI,CAAC,OAAO,QAAS,QAAO,OAAO;AACnC,QAAM,SAAS,WAAW,QAAQ,QAAQ,IAAI,QAAQ,GAAG,OAAO,UAAU;AAC1E,SAAO,sBAAsB,MAAM,IAAI,SAAS,OAAO;AACzD;AAPgB;AAShB,SAAS,WAAW,cAA6B,MAAkC;AACjF,MAAI,CAAC,aAAc,QAAO;AAC1B,aAAW,SAAS,aAAa,MAAM,GAAG,GAAG;AAC3C,UAAM,YAAY,MAAM,QAAQ,GAAG;AACnC,QAAI,YAAY,EAAG;AACnB,UAAM,MAAM,kBAAkB,MAAM,MAAM,GAAG,SAAS,EAAE,KAAK,CAAC;AAC9D,QAAI,QAAQ,KAAM;AAClB,WAAO,kBAAkB,MAAM,MAAM,YAAY,CAAC,EAAE,KAAK,CAAC;AAAA,EAC5D;AACA,SAAO;AACT;AAVS;AAYT,SAAS,kBAAkB,OAAuB;AAChD,MAAI;AACF,WAAO,mBAAmB,KAAK;AAAA,EACjC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AANS;AAQT,SAAS,sBAAsB,OAA8C;AAC3E,SAAO,UAAU,WAAW,UAAU,UAAU,UAAU;AAC5D;AAFS;AAIT,oCAAoC,MAAM;AACxC,MAAI;AACF,WAAO,iBAAiB;AAAA,EAC1B,QAAQ;AACN,UAAM,QAAQ,mBAAmB;AACjC,WAAO;AAAA,MACL;AAAA,MACA,eAAe,UAAU,WAAW,SAAY;AAAA,MAChD,SAAS;AAAA,IACX;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFarmThemeServerSnapshot
|
|
3
|
+
} from "./chunk-GQVQESLY.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-CGILA3WO.mjs";
|
|
7
|
+
|
|
8
|
+
// src/theme/client.tsx
|
|
9
|
+
import { useSyncExternalStore } from "react";
|
|
10
|
+
var FALLBACK_CLIENT_SNAPSHOT = Object.freeze({
|
|
11
|
+
theme: "system",
|
|
12
|
+
resolvedTheme: "light",
|
|
13
|
+
mounted: true
|
|
14
|
+
});
|
|
15
|
+
var cachedClientSnapshot = FALLBACK_CLIENT_SNAPSHOT;
|
|
16
|
+
function snapshotsMatch(left, right) {
|
|
17
|
+
return left.theme === right.theme && left.resolvedTheme === right.resolvedTheme && left.mounted === right.mounted;
|
|
18
|
+
}
|
|
19
|
+
__name(snapshotsMatch, "snapshotsMatch");
|
|
20
|
+
function getClientSnapshot() {
|
|
21
|
+
const next = typeof window === "undefined" ? FALLBACK_CLIENT_SNAPSHOT : window.__FARM_THEME__?.snapshot;
|
|
22
|
+
if (!next) return cachedClientSnapshot;
|
|
23
|
+
if (!snapshotsMatch(cachedClientSnapshot, next)) cachedClientSnapshot = next;
|
|
24
|
+
return cachedClientSnapshot;
|
|
25
|
+
}
|
|
26
|
+
__name(getClientSnapshot, "getClientSnapshot");
|
|
27
|
+
function getHydrationSnapshot() {
|
|
28
|
+
if (typeof window !== "undefined" && window.__FARM_THEME__?.serverSnapshot) {
|
|
29
|
+
return window.__FARM_THEME__.serverSnapshot;
|
|
30
|
+
}
|
|
31
|
+
return getFarmThemeServerSnapshot();
|
|
32
|
+
}
|
|
33
|
+
__name(getHydrationSnapshot, "getHydrationSnapshot");
|
|
34
|
+
function subscribe(listener) {
|
|
35
|
+
if (typeof window === "undefined") return () => {
|
|
36
|
+
};
|
|
37
|
+
const handleThemeChange = /* @__PURE__ */ __name(() => {
|
|
38
|
+
getClientSnapshot();
|
|
39
|
+
listener();
|
|
40
|
+
}, "handleThemeChange");
|
|
41
|
+
window.addEventListener("farm:themechange", handleThemeChange);
|
|
42
|
+
return () => window.removeEventListener("farm:themechange", handleThemeChange);
|
|
43
|
+
}
|
|
44
|
+
__name(subscribe, "subscribe");
|
|
45
|
+
function getTheme() {
|
|
46
|
+
return getClientSnapshot();
|
|
47
|
+
}
|
|
48
|
+
__name(getTheme, "getTheme");
|
|
49
|
+
function setTheme(theme) {
|
|
50
|
+
const runtime = typeof window === "undefined" ? void 0 : window.__FARM_THEME__;
|
|
51
|
+
if (!runtime) {
|
|
52
|
+
throw new Error("The FARMJS theme runtime is not enabled. Add `theme` to farm.config.ts.");
|
|
53
|
+
}
|
|
54
|
+
runtime.setTheme(theme);
|
|
55
|
+
}
|
|
56
|
+
__name(setTheme, "setTheme");
|
|
57
|
+
function toggleTheme() {
|
|
58
|
+
const next = getClientSnapshot().resolvedTheme === "dark" ? "light" : "dark";
|
|
59
|
+
setTheme(next);
|
|
60
|
+
return next;
|
|
61
|
+
}
|
|
62
|
+
__name(toggleTheme, "toggleTheme");
|
|
63
|
+
function useTheme() {
|
|
64
|
+
const snapshot = useSyncExternalStore(subscribe, getClientSnapshot, getHydrationSnapshot);
|
|
65
|
+
return {
|
|
66
|
+
...snapshot,
|
|
67
|
+
setTheme,
|
|
68
|
+
toggleTheme
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
__name(useTheme, "useTheme");
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
getTheme,
|
|
75
|
+
setTheme,
|
|
76
|
+
toggleTheme,
|
|
77
|
+
useTheme
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=chunk-D42BNPZH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/theme/client.tsx"],"sourcesContent":["\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\nimport { getFarmThemeServerSnapshot } from \"./bridge\";\nimport type {\n FarmThemePreference,\n FarmThemeRuntime,\n FarmThemeSnapshot,\n FarmResolvedTheme,\n} from \"./types\";\n\ndeclare global {\n interface Window {\n __FARM_THEME__?: FarmThemeRuntime;\n }\n}\n\nconst FALLBACK_CLIENT_SNAPSHOT: FarmThemeSnapshot = Object.freeze({\n theme: \"system\",\n resolvedTheme: \"light\",\n mounted: true,\n});\n\nlet cachedClientSnapshot = FALLBACK_CLIENT_SNAPSHOT;\n\nfunction snapshotsMatch(left: FarmThemeSnapshot, right: FarmThemeSnapshot): boolean {\n return (\n left.theme === right.theme &&\n left.resolvedTheme === right.resolvedTheme &&\n left.mounted === right.mounted\n );\n}\n\nfunction getClientSnapshot(): FarmThemeSnapshot {\n const next =\n typeof window === \"undefined\" ? FALLBACK_CLIENT_SNAPSHOT : window.__FARM_THEME__?.snapshot;\n if (!next) return cachedClientSnapshot;\n if (!snapshotsMatch(cachedClientSnapshot, next)) cachedClientSnapshot = next;\n return cachedClientSnapshot;\n}\n\nfunction getHydrationSnapshot(): FarmThemeSnapshot {\n if (typeof window !== \"undefined\" && window.__FARM_THEME__?.serverSnapshot) {\n return window.__FARM_THEME__.serverSnapshot;\n }\n return getFarmThemeServerSnapshot();\n}\n\nfunction subscribe(listener: () => void): () => void {\n if (typeof window === \"undefined\") return () => {};\n const handleThemeChange = () => {\n getClientSnapshot();\n listener();\n };\n window.addEventListener(\"farm:themechange\", handleThemeChange);\n return () => window.removeEventListener(\"farm:themechange\", handleThemeChange);\n}\n\nexport function getTheme(): FarmThemeSnapshot {\n return getClientSnapshot();\n}\n\nexport function setTheme(theme: FarmThemePreference): void {\n const runtime = typeof window === \"undefined\" ? undefined : window.__FARM_THEME__;\n if (!runtime) {\n throw new Error(\"The FARMJS theme runtime is not enabled. Add `theme` to farm.config.ts.\");\n }\n runtime.setTheme(theme);\n}\n\nexport function toggleTheme(): FarmResolvedTheme {\n const next = getClientSnapshot().resolvedTheme === \"dark\" ? \"light\" : \"dark\";\n setTheme(next);\n return next;\n}\n\nexport interface UseThemeResult extends FarmThemeSnapshot {\n setTheme(theme: FarmThemePreference): void;\n toggleTheme(): FarmResolvedTheme;\n}\n\nexport function useTheme(): UseThemeResult {\n const snapshot = useSyncExternalStore(subscribe, getClientSnapshot, getHydrationSnapshot);\n return {\n ...snapshot,\n setTheme,\n toggleTheme,\n };\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,4BAA4B;AAerC,IAAM,2BAA8C,OAAO,OAAO;AAAA,EAChE,OAAO;AAAA,EACP,eAAe;AAAA,EACf,SAAS;AACX,CAAC;AAED,IAAI,uBAAuB;AAE3B,SAAS,eAAe,MAAyB,OAAmC;AAClF,SACE,KAAK,UAAU,MAAM,SACrB,KAAK,kBAAkB,MAAM,iBAC7B,KAAK,YAAY,MAAM;AAE3B;AANS;AAQT,SAAS,oBAAuC;AAC9C,QAAM,OACJ,OAAO,WAAW,cAAc,2BAA2B,OAAO,gBAAgB;AACpF,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI,CAAC,eAAe,sBAAsB,IAAI,EAAG,wBAAuB;AACxE,SAAO;AACT;AANS;AAQT,SAAS,uBAA0C;AACjD,MAAI,OAAO,WAAW,eAAe,OAAO,gBAAgB,gBAAgB;AAC1E,WAAO,OAAO,eAAe;AAAA,EAC/B;AACA,SAAO,2BAA2B;AACpC;AALS;AAOT,SAAS,UAAU,UAAkC;AACnD,MAAI,OAAO,WAAW,YAAa,QAAO,MAAM;AAAA,EAAC;AACjD,QAAM,oBAAoB,6BAAM;AAC9B,sBAAkB;AAClB,aAAS;AAAA,EACX,GAH0B;AAI1B,SAAO,iBAAiB,oBAAoB,iBAAiB;AAC7D,SAAO,MAAM,OAAO,oBAAoB,oBAAoB,iBAAiB;AAC/E;AARS;AAUF,SAAS,WAA8B;AAC5C,SAAO,kBAAkB;AAC3B;AAFgB;AAIT,SAAS,SAAS,OAAkC;AACzD,QAAM,UAAU,OAAO,WAAW,cAAc,SAAY,OAAO;AACnE,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,yEAAyE;AAAA,EAC3F;AACA,UAAQ,SAAS,KAAK;AACxB;AANgB;AAQT,SAAS,cAAiC;AAC/C,QAAM,OAAO,kBAAkB,EAAE,kBAAkB,SAAS,UAAU;AACtE,WAAS,IAAI;AACb,SAAO;AACT;AAJgB;AAWT,SAAS,WAA2B;AACzC,QAAM,WAAW,qBAAqB,WAAW,mBAAmB,oBAAoB;AACxF,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;AAPgB;","names":[]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-V7RBCSDJ.mjs";
|
|
5
5
|
import {
|
|
6
6
|
resolveDocsConfig
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YD5IRKVS.mjs";
|
|
8
8
|
import {
|
|
9
9
|
resolveFarmDocsFontAssets,
|
|
10
10
|
toFarmDocsPublicFontAssets
|
|
@@ -4002,4 +4002,4 @@ export {
|
|
|
4002
4002
|
createDocsAPI,
|
|
4003
4003
|
createFarmDocsAPIHandler
|
|
4004
4004
|
};
|
|
4005
|
-
//# sourceMappingURL=chunk-
|
|
4005
|
+
//# sourceMappingURL=chunk-DVPRBMU2.mjs.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-CGILA3WO.mjs";
|
|
4
|
+
|
|
5
|
+
// src/theme/bridge.ts
|
|
6
|
+
var FALLBACK_SERVER_SNAPSHOT = Object.freeze({
|
|
7
|
+
theme: "system",
|
|
8
|
+
resolvedTheme: void 0,
|
|
9
|
+
mounted: false
|
|
10
|
+
});
|
|
11
|
+
var FARM_THEME_SERVER_SNAPSHOT_RESOLVER = /* @__PURE__ */ Symbol.for("farm.js.theme.server-snapshot-resolver");
|
|
12
|
+
function _setFarmThemeServerSnapshotResolver(resolver) {
|
|
13
|
+
globalThis[FARM_THEME_SERVER_SNAPSHOT_RESOLVER] = resolver;
|
|
14
|
+
}
|
|
15
|
+
__name(_setFarmThemeServerSnapshotResolver, "_setFarmThemeServerSnapshotResolver");
|
|
16
|
+
function getFarmThemeServerSnapshot() {
|
|
17
|
+
return globalThis[FARM_THEME_SERVER_SNAPSHOT_RESOLVER]?.() ?? FALLBACK_SERVER_SNAPSHOT;
|
|
18
|
+
}
|
|
19
|
+
__name(getFarmThemeServerSnapshot, "getFarmThemeServerSnapshot");
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
_setFarmThemeServerSnapshotResolver,
|
|
23
|
+
getFarmThemeServerSnapshot
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-GQVQESLY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/theme/bridge.ts"],"sourcesContent":["import type { FarmThemeSnapshot } from \"./types\";\n\nconst FALLBACK_SERVER_SNAPSHOT: FarmThemeSnapshot = Object.freeze({\n theme: \"system\",\n resolvedTheme: undefined,\n mounted: false,\n});\n\nconst FARM_THEME_SERVER_SNAPSHOT_RESOLVER = Symbol.for(\"farm.js.theme.server-snapshot-resolver\");\n\ntype FarmThemeBridgeGlobal = typeof globalThis & {\n [FARM_THEME_SERVER_SNAPSHOT_RESOLVER]?: () => FarmThemeSnapshot;\n};\n\nexport function _setFarmThemeServerSnapshotResolver(resolver: () => FarmThemeSnapshot): void {\n (globalThis as FarmThemeBridgeGlobal)[FARM_THEME_SERVER_SNAPSHOT_RESOLVER] = resolver;\n}\n\nexport function getFarmThemeServerSnapshot(): FarmThemeSnapshot {\n return (\n (globalThis as FarmThemeBridgeGlobal)[FARM_THEME_SERVER_SNAPSHOT_RESOLVER]?.() ??\n FALLBACK_SERVER_SNAPSHOT\n );\n}\n"],"mappings":";;;;;AAEA,IAAM,2BAA8C,OAAO,OAAO;AAAA,EAChE,OAAO;AAAA,EACP,eAAe;AAAA,EACf,SAAS;AACX,CAAC;AAED,IAAM,sCAAsC,uBAAO,IAAI,wCAAwC;AAMxF,SAAS,oCAAoC,UAAyC;AAC3F,EAAC,WAAqC,mCAAmC,IAAI;AAC/E;AAFgB;AAIT,SAAS,6BAAgD;AAC9D,SACG,WAAqC,mCAAmC,IAAI,KAC7E;AAEJ;AALgB;","names":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-CGILA3WO.mjs";
|
|
4
|
+
|
|
5
|
+
// src/theme/config.ts
|
|
6
|
+
var DEFAULT_FARM_THEME_STORAGE_KEY = "farm-theme";
|
|
7
|
+
var STORAGE_KEY_PATTERN = /^[A-Za-z0-9._-]+$/;
|
|
8
|
+
function resolveFarmThemeConfig(config, basePath = "/") {
|
|
9
|
+
if (config && "enabled" in config) {
|
|
10
|
+
return config;
|
|
11
|
+
}
|
|
12
|
+
if (!config) {
|
|
13
|
+
return {
|
|
14
|
+
enabled: false,
|
|
15
|
+
default: "system",
|
|
16
|
+
storageKey: DEFAULT_FARM_THEME_STORAGE_KEY,
|
|
17
|
+
cookiePath: normalizeCookiePath(basePath)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const storageKey = config.storageKey?.trim() || DEFAULT_FARM_THEME_STORAGE_KEY;
|
|
21
|
+
if (!STORAGE_KEY_PATTERN.test(storageKey)) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
"theme.storageKey may only contain letters, numbers, dots, underscores, and hyphens."
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
const defaultTheme = config.default ?? "system";
|
|
27
|
+
if (defaultTheme !== "light" && defaultTheme !== "dark" && defaultTheme !== "system") {
|
|
28
|
+
throw new Error('theme.default must be "light", "dark", or "system".');
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
enabled: true,
|
|
32
|
+
default: defaultTheme,
|
|
33
|
+
storageKey,
|
|
34
|
+
cookiePath: normalizeCookiePath(basePath)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
__name(resolveFarmThemeConfig, "resolveFarmThemeConfig");
|
|
38
|
+
function normalizeCookiePath(basePath) {
|
|
39
|
+
const normalized = `/${basePath}`.replace(/\/{2,}/g, "/");
|
|
40
|
+
if (normalized === "/") return normalized;
|
|
41
|
+
return normalized.replace(/\/$/, "");
|
|
42
|
+
}
|
|
43
|
+
__name(normalizeCookiePath, "normalizeCookiePath");
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
resolveFarmThemeConfig
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=chunk-H53KVQUU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/theme/config.ts"],"sourcesContent":["import type { FarmThemeConfig, ResolvedFarmThemeConfig } from \"./types\";\n\nexport const DEFAULT_FARM_THEME_STORAGE_KEY = \"farm-theme\";\n\nconst STORAGE_KEY_PATTERN = /^[A-Za-z0-9._-]+$/;\n\nexport function resolveFarmThemeConfig(\n config: FarmThemeConfig | ResolvedFarmThemeConfig | false | undefined,\n basePath = \"/\",\n): ResolvedFarmThemeConfig {\n if (config && \"enabled\" in config) {\n return config;\n }\n\n if (!config) {\n return {\n enabled: false,\n default: \"system\",\n storageKey: DEFAULT_FARM_THEME_STORAGE_KEY,\n cookiePath: normalizeCookiePath(basePath),\n };\n }\n\n const storageKey = config.storageKey?.trim() || DEFAULT_FARM_THEME_STORAGE_KEY;\n if (!STORAGE_KEY_PATTERN.test(storageKey)) {\n throw new Error(\n \"theme.storageKey may only contain letters, numbers, dots, underscores, and hyphens.\",\n );\n }\n\n const defaultTheme = config.default ?? \"system\";\n if (defaultTheme !== \"light\" && defaultTheme !== \"dark\" && defaultTheme !== \"system\") {\n throw new Error('theme.default must be \"light\", \"dark\", or \"system\".');\n }\n\n return {\n enabled: true,\n default: defaultTheme,\n storageKey,\n cookiePath: normalizeCookiePath(basePath),\n };\n}\n\nfunction normalizeCookiePath(basePath: string): string {\n const normalized = `/${basePath}`.replace(/\\/{2,}/g, \"/\");\n if (normalized === \"/\") return normalized;\n return normalized.replace(/\\/$/, \"\");\n}\n"],"mappings":";;;;;AAEO,IAAM,iCAAiC;AAE9C,IAAM,sBAAsB;AAErB,SAAS,uBACd,QACA,WAAW,KACc;AACzB,MAAI,UAAU,aAAa,QAAQ;AACjC,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,MACL,SAAS;AAAA,MACT,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,YAAY,oBAAoB,QAAQ;AAAA,IAC1C;AAAA,EACF;AAEA,QAAM,aAAa,OAAO,YAAY,KAAK,KAAK;AAChD,MAAI,CAAC,oBAAoB,KAAK,UAAU,GAAG;AACzC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe,OAAO,WAAW;AACvC,MAAI,iBAAiB,WAAW,iBAAiB,UAAU,iBAAiB,UAAU;AACpF,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AAEA,SAAO;AAAA,IACL,SAAS;AAAA,IACT,SAAS;AAAA,IACT;AAAA,IACA,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AACF;AAnCgB;AAqChB,SAAS,oBAAoB,UAA0B;AACrD,QAAM,aAAa,IAAI,QAAQ,GAAG,QAAQ,WAAW,GAAG;AACxD,MAAI,eAAe,IAAK,QAAO;AAC/B,SAAO,WAAW,QAAQ,OAAO,EAAE;AACrC;AAJS;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-HCGQYYHI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|